package com.hxzy.goods.mapper;

import com.hxzy.goods.pojo.Brand;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

@Repository
public interface BrandMapper extends Mapper<Brand> {

    @Update("update tb_brand set state=0 where id=#{id}")
    public int deleteById(int id);

    @Select("SELECT name,image FROM tb_brand WHERE id  IN (SELECT brand_id FROM tb_category_brand WHERE  category_id IN (SELECT id FROM tb_category WHERE NAME=#{categoryName}) ) order by seq")
    public List<Map> findListByCategoryName(String categoryName);

    @Select("SELECT name,options FROM tb_spec WHERE template_id IN ( SELECT template_id FROM tb_category WHERE NAME=#{categoryName}) order by seq")
    public List<Map> findSpecListByCategoryName(String categoryName);
}
